const DATA_LIST = [
  {
    'id': '52bA0A8e-Df2d-856a-E5eD-8C73bAdE5fC5',
    'name': '任娟',
    'age': 24,
    'birth': '1997-03-28',
    'email': 'v.urs@iozcutn.cq',
    'sex': '男'
  }, {
    'id': '862dF116-36ae-8CEE-36bD-6c4B412bD670',
    'name': '尹勇',
    'age': 18,
    'birth': '2003-09-10',
    'email': 'i.cfyccpyfiw@rjtbrbm.lb',
    'sex': '男'
  }, {
    'id': 'FD11cf5B-5Fb1-6FFc-D77f-4f4064f9aFfa',
    'name': '冯艳',
    'age': 31,
    'birth': '1990-06-17',
    'email': 'h.bwkotlrxs@xamnjv.ch',
    'sex': '女'
  }, {
    'id': 'd6cec24E-f20e-396b-d451-58EEe6d0c67D',
    'name': '邵杰',
    'age': 24,
    'birth': '1997-03-12',
    'email': 'm.hhkpsamles@deeotbtp.dz',
    'sex': '男'
  }, {
    'id': 'A3CFe7Ec-15FA-B1a2-Cb45-b44AD6FfCD05',
    'name': '段勇',
    'age': 21,
    'birth': '2000-11-09',
    'email': 's.oeyjx@opnkefxf.be',
    'sex': '男'
  }, {
    'id': '0BC2EaA6-C138-DdD8-EFC8-8A3dAdE2a7EF',
    'name': '卢丽',
    'age': 32,
    'birth': '1989-04-23',
    'email': 'd.asvfpyt@cmnri.kp',
    'sex': '男'
  }, {
    'id': '69566c09-8A79-Ef64-9582-C38eABCADD3f',
    'name': '萧娟',
    'age': 25,
    'birth': '1996-10-19',
    'email': 'j.hmj@mee.bd',
    'sex': '男'
  }, {
    'id': 'A9bf1B4D-ccba-4c43-9786-8D5DDdF1b2cf',
    'name': '彭磊',
    'age': 30,
    'birth': '1991-05-26',
    'email': 'j.znxdg@llcdsm.is',
    'sex': '保密'
  }, {
    'id': '2c1Eee4F-BB63-1e3e-b25F-9af42F8Fae5c',
    'name': '汪秀兰',
    'age': 32,
    'birth': '1989-06-23',
    'email': 'i.tpje@lptshrz.gl',
    'sex': '保密'
  }, {
    'id': 'e8CC7050-4FD3-39A7-7bc1-9cDB4FB2770d',
    'name': '何磊',
    'age': 39,
    'birth': '1982-09-17',
    'email': 't.icqe@ymbujwfnod.sd',
    'sex': '女'
  }, {
    'id': 'd5ed5A6b-3DEB-129b-ecE1-Fe59C14BefC9',
    'name': '黎芳',
    'age': 22,
    'birth': '1999-07-17',
    'email': 'g.yfffsk@sskl.ev',
    'sex': '男'
  }, {
    'id': '98De3B25-bE58-6AA5-A553-b845Dc97dd91',
    'name': '彭涛',
    'age': 26,
    'birth': '1995-09-25',
    'email': 'v.vxhyjkkqif@sanw.ph',
    'sex': '男'
  }, {
    'id': '8B3EBcdd-9CCD-6443-d7b8-Ce1A1eD4Cd39',
    'name': '魏敏',
    'age': 23,
    'birth': '1998-08-24',
    'email': 'm.fdpwr@dhyeluu.co',
    'sex': '男'
  }, {
    'id': 'a4A7f755-FccD-Eb6f-Fd46-Ef27baDD4c98',
    'name': '杜超',
    'age': 27,
    'birth': '1994-03-21',
    'email': 't.jkrkfjgo@ymlxsy.uy',
    'sex': '保密'
  }, {
    'id': 'fbBBFb1d-2D7f-DCd2-FcC4-17Fb6A6B3fCC',
    'name': '萧秀兰',
    'age': 29,
    'birth': '1992-08-08',
    'email': 'w.jyuw@bkirhdbh.ao',
    'sex': '保密'
  }, {
    'id': '2452fd54-05Eb-be6d-B817-00B2C59d1edd',
    'name': '易静',
    'age': 26,
    'birth': '1995-12-12',
    'email': 'f.bgkdplknis@dfktmxmxi.cn',
    'sex': '男'
  }, {
    'id': '6F81b7C9-A65e-7bCB-3C52-086D329be18c',
    'name': '贾秀兰',
    'age': 29,
    'birth': '1992-12-04',
    'email': 'd.reubyfir@nclp.aw',
    'sex': '男'
  }, {
    'id': '07ab7B1c-dfE2-FB43-7bd1-FeC3925519C2',
    'name': '杨敏',
    'age': 37,
    'birth': '1984-11-07',
    'email': 'j.ufqfrklx@vrmtnolvhq.mz',
    'sex': '男'
  }, {
    'id': 'F65C2aAb-be60-81Fe-b2Ca-d6C44602Ce91',
    'name': '易伟',
    'age': 29,
    'birth': '1992-04-30',
    'email': 't.lqaw@dovojji.ie',
    'sex': '男'
  }, {
    'id': '2D79f860-b33A-F7aF-53bA-3de8ee0feB9f',
    'name': '蔡静',
    'age': 39,
    'birth': '1982-06-20',
    'email': 'a.mcdm@daicpe.cd',
    'sex': '保密'
  }, {
    'id': 'b5f630Db-c4Ee-2bF6-6bD4-3967c4bE2f9E',
    'name': '顾强',
    'age': 22,
    'birth': '1999-04-20',
    'email': 'h.walit@dht.is',
    'sex': '保密'
  }, {
    'id': 'FFAF971E-febf-AAdE-12CC-b4BBfCB0DA8e',
    'name': '胡平',
    'age': 25,
    'birth': '1996-07-28',
    'email': 'w.aphyga@kczymtapth.pn',
    'sex': '女'
  }, {
    'id': 'fbBdaefB-4FBC-7899-c949-b6F7f5352Ab9',
    'name': '袁强',
    'age': 33,
    'birth': '1988-01-28',
    'email': 'm.wfhgh@unsfdiqmy.re',
    'sex': '保密'
  }, {
    'id': '2aF8e1E3-5bb7-C0fb-ea5b-4b7efCEe7f67',
    'name': '康静',
    'age': 31,
    'birth': '1990-06-13',
    'email': 'r.svgqbltp@wlewds.pa',
    'sex': '男'
  }, {
    'id': 'D2e145c9-b1A7-Fe33-8DbE-fF1b1deB4B17',
    'name': '周勇',
    'age': 32,
    'birth': '1989-10-20',
    'email': 't.ypsrxgzxb@cgnjmpx.af',
    'sex': '男'
  }
]

let idIndex = 0

export function getExample (params) {
  return new Promise(resolve => {
    let current = params.pageNo || 1
    const size = params.limit || 20
    const pages = Math.ceil(DATA_LIST.length / size)
    current = Math.min(current, pages)
    const START = (current - 1) * size
    const records = DATA_LIST.slice(START, START + size)

    resolve({
      code: 0,
      data: {
        records, current, size, pages, total: DATA_LIST.length
      },
      msg: 'success'
    })
  })
}

export function postExample (params) {
  return new Promise(resolve => {
    DATA_LIST.push({
      ...params,
      id: idIndex++
    })

    resolve({
      code: 0,
      msg: 'success'
    })
  })
}

export function putExample (params) {
  return new Promise(resolve => {
    const data = DATA_LIST.find(item => item.id === params.id)

    Object.assign(data, params)

    resolve({
      code: 0,
      msg: 'success'
    })
  })
}

export function delExample (id) {
  return new Promise(resolve => {
    const dataIndex = DATA_LIST.findIndex(item => item.id === id)

    DATA_LIST.splice(dataIndex, 1)

    resolve({
      code: 0,
      msg: 'success'
    })
  })
}